< previous page page_384 next page >

Page 384
On my 133MHz Pentium, program Panview1 draws its smiley face just a little too slowly to pan without flickering. If you click and drag the scrollbar thumbs, you will see a slight but noticeable flicker.
Example program Panview2 is similar to program Panviewl but uses different zooming and scrolling styles. Rather than providing certain fixed-scale factors, this program lets you zoom in on an arbitrary region. To do this, select the Zoom command from the Scale menu. Then click and drag to select the area in the picture that you would like to examine more closely. The program adjusts the world window so that it has the correct aspect ratio before it updates the picture.
Panview2 does not scroll its picture as you drag a scrollbar's thumb. If you grab a thumb and drag it, the program waits until you release the thumb before it updates the world window's boundaries. This method is particularly useful if the picture you are drawing is extremely complicated and redrawing whenever the thumb moves causes the image to flicker annoyingly.
Two-Dimensional Transformations
By changing the world window mapping, you can easily move a picture to another part of a viewport. If the picture contains more than one object, you might like to move one of the objects without moving the others. In that case, you cannot use the world window mapping to move the object because that would move the other objects as well.
Instead you can apply a transformation to the object you want to move. A transformation changes the position of the points and lines that make up the object. The following sections describe transformations that translate, scale, and rotate an object.
Some Visual Basic drawing methods do not transform easily. The Circle method, for instance, can draw arcs of ellipses. While the Circle method can draw arcs that have been scaled or translated, it cannot draw an arc that has been rotated. Similarly, you can use the Line method to draw a rectangle as shown in the following code:
e10a6a0a59f035e870d90cca05b85fce.gif
Line (x1, y1) - (x2, y2), , B
You can modify this statement to draw a rectangle that has been scaled or translated but not one that has been rotated. To draw a rotated rectangle, you must use the Line command four times, once for each side of the rectangle. Figure 12.9 shows some arcs and rectangles that Visual Basic's Circle and Line commands cannot draw directly.
You can draw these sorts of shapes using the Line command. If you draw an arc as a sequence of short line segments, you can transform the arc by transforming the points that make up the segments. If the segments are small enough, the arc appears smooth to the user. Chapter 11, Drawing Curves, discusses this sort of curve drawing in detail.

 
< previous page page_384 next page >